using System.ComponentModel;
using UnityEngine;
using UnityEngine.UI;


namespace HXSJFrameWork
{
    /// <summary>
    /// UI|遮罩层管理
    /// </summary>
    public class UseBlackMask : MonoBehaviour
    {
        public void Awake()
        {
            this.SetColor(MaskColorType.Black);
        }



        public void SetState(bool isEnable)
        {
            if (transform.gameObject.activeSelf != isEnable)
            {
                transform.gameObject.SetActive(isEnable);
            }
        }
        public void SetColor(MaskColorType type)
        {
            Color color = type switch
            {
                MaskColorType.None => new Color(1, 1, 1, 0),
                MaskColorType.Black => new Color(0, 0, 0, 0.35f),
                _ => new Color(0, 0, 0, 0.35f)
            };

            this.SetColor(color);
        }
        public void SetColor(Color color)
        {
            if (transform.TryGetComponent(out Image mask))
            {
                mask.color = color;
            }
        }
    }


    public enum MaskColorType
    {
        [Description("透明")] None,
        [Description("黑色")] Black,
    }
}
